package oop.day05;



public class RefDemo {
    public static void main(String[] args) {
       Dog[] dogs= new Dog[5];
       dogs[0]= new Dog("小白",3,"白色");
       dogs[1]= new Dog("小黑",4,"黑色");
       dogs[2]= new Dog("小黄",5,"黄色");
       dogs[3]= new Dog("小灰",6,"灰色");
       dogs[4]= new Dog("小蓝",7,"蓝色");
        System.out.println(dogs[1].age);
        System.out.println(dogs[2].name);
        dogs[1].eat();
        dogs[1].lookHome();
        dogs[1].swim();
        for (int i = 0; i < dogs.length; i++) {
            System.out.println("---------");
            System.out.println(dogs[i].age);
            System.out.println(dogs[i].name);
            dogs[i].eat();
            dogs[i].lookHome();
            dogs[i].swim();
        }

        Dog dog4=dogs[4];
        dog4.eat();
        System.out.println(dog4.name);

        Dog dog44= new Dog("小绿",7,"绿色");
        dogs[4]=dog44;
        System.out.println(dogs[4].name);

        Fish[] fishs= new Fish[3];
        fishs[0]=new Fish("小金",2,"金色");
        fishs[1]=new Fish("小红",3,"红色");
        fishs[2]=new Fish("小黑",4,"黑色");
        for (Fish fish: fishs) {
            System.out.println("--------");
            System.out.println(fish.name);
            fish.eat();
            fish.swim();
        }


















        int a=4;
        int[] arr=new int[4];
        arr[0]=4;
        String[] str=new String[4];

        Dog d=new Dog();
        // 创建了 dog类型的数组，每一个位置元素放 dog对象
        Dog[] dArr=new Dog[4];
        Chick[] cArr=new Chick[4];
        Fish[] fArr=new Fish[4];



    }
}
